package com.moleq.mgpos.widget;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.moleq.base.AsyncImageLoader;
import com.moleq.base.MoleQBaseDialog;
import com.moleq.base.OnResultListener;
import com.moleq.base.SmartBeep;
import com.moleq.base.AsyncImageLoader.ImageCallback;
import com.moleq.device.DeviceManager;
import com.moleq.dialog.InputQtyInfoDialog;
import com.moleq.dialog.MessageBox;
import com.moleq.logic.TransactionManager;
import com.moleq.logic.SaleList.OnItemDisplayListener;
import com.moleq.models.Departmant;
import com.moleq.models.FlipChart;
import com.moleq.models.GlobalInfo;
import com.moleq.models.PriceSetting;
import com.moleq.models.Product;
import com.moleq.models.SaleListItem;
import com.moleq.models.SubDepartmant;
import com.moleq.models.TareSetting;
import com.moleq.mgpos.activities.R;
import com.moleq.service.FlipChartService;
import com.moleq.service.ItemPicService;
import com.moleq.service.ProductService;
import com.moleq.service.ServiceManager;
import com.moleq.service.SubDepartmantService;
import com.moleq.test.MyGestureListener;
import com.moleq.util.BigDecmialTool;
import com.moleq.util.MoleQUtil;

public class FlipChartPanel extends LinearLayout implements OnItemDisplayListener,OnResultListener {

	private LayoutParams LP_FF = new LayoutParams(LayoutParams.FILL_PARENT,
			LayoutParams.FILL_PARENT);
	private PopupWindow mPopupWindow;
	private Context mContext;
	private ProductService mProductService;
	private ArrayList<SaleListItem> mFlipChartItems;
	private TransactionManager mTransMgr;
	private DeviceManager mDeviceMgr;
	private LayoutInflater mInflater;
	private View mView;
	private ImageButton mImageButtonClose;
	private TextView mTextViewContent1;
	private TextView mTextViewContent2;
	private TextView mTextViewTotal;
	private TextView mTextViewUnitPrice;
	private ListView mListView;
	private MyGestureListener myGestureListener;
	private FlipChartRowAdapter mAdapter;
	private int mWidth;
	private int mHeight;
	private OnTouchFlipChartListener mOnTouchFlipChartListener;
	private int mCurrentPage;
	public int mPageCount;
	public int mRecordCount;
	public int mPages;
	public int mJumpPage; 
	private int mPageSize = 100;
	private FlipChartService mFlipChartSrv;
	private TextView mTextViewWeight;
	private boolean mIsShowing;
	private TextView mLabelPrice;
	private TextView mLabelTotal;
	private int qty = 1;
	private TextView mtextViewMultiplier;
	private ImageButton mimageButtonCross;
	private SubDepartmant deptSetting;
	private SubDepartmantService mSubDepartmantService;
	public FlipChartPanel(Context context) {
		super(context);
	}
	
	public FlipChartPanel(Context context, AttributeSet attrs) {

		super(context, attrs);
	}
	
	public FlipChartPanel(Context context,int width,int height) {

		super(context);
		
		mContext = context;
		
		mTransMgr = TransactionManager.getInstance();
        mDeviceMgr = DeviceManager.getInstance();
		mProductService = ServiceManager.getInstance().mProductService; //new ProductService(shareContext);
//		mPicService = new ItemPicService(context, shareContext);
		mFlipChartSrv = ServiceManager.getInstance().mFlipChartService;//new FlipChartService(context,shareContext);
		mSubDepartmantService  = ServiceManager.getInstance().mSubDepartmantService;
		
		mFlipChartItems =  new ArrayList<SaleListItem>();
		mRecordCount = Calc();
		mPageCount = mRecordCount / mPageSize + OverPage();  
		mCurrentPage = (mPageCount>0)?  1: 0;
		
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
        mView = mInflater.inflate(R.layout.flip_chart, null);
        
        
        mImageButtonClose = (ImageButton)mView.findViewById(R.id.imageButtonClose);
        mimageButtonCross = (ImageButton)mView.findViewById(R.id.imageButtonCross);
        mImageButtonClose.setOnClickListener(onClickListener);
        mimageButtonCross.setOnClickListener(onClickListener);
        
		mTextViewContent1 = (TextView) mView.findViewById(R.id.textViewContent1);
		mTextViewContent2 = (TextView) mView.findViewById(R.id.textViewContent2);
		mTextViewWeight = (TextView)mView.findViewById(R.id.textViewWeight);
		mTextViewTotal = (TextView) mView.findViewById(R.id.textViewTotal);
		mTextViewUnitPrice = (TextView) mView.findViewById(R.id.textViewUnitPrice);
		mtextViewMultiplier = (TextView) mView.findViewById(R.id.textViewMultiplier);
		
		mLabelPrice = (TextView)mView.findViewById(R.id.tvLabelFlipChartPrice);
		mLabelTotal = (TextView)mView.findViewById(R.id.tvLabelFlipChartTotal);
		mLabelPrice.setText(String.format(mContext.getResources().getString(R.string.label_price), GlobalInfo.getInstance().CurrencySymbol));
		mLabelTotal.setText(String.format(mContext.getResources().getString(R.string.label_total), GlobalInfo.getInstance().CurrencySymbol));
		
		mListView = (ListView) mView.findViewById(R.id.listViewFlipChartItem);
	        
//        myGestureListener = new MyGestureListener(context,null,this); 
        mAdapter = new FlipChartRowAdapter(context);
        mAdapter.setNumColumns(5);
        mAdapter.setSource(mFlipChartItems);
        mListView.setAdapter(mAdapter);
       
        
      //  mGridView.setOnTouchListener(myGestureListener);
      //  mListView.setOnItemClickListener( onItemClickListener);
       
        
        //半透明效果
  		ColorDrawable dw = new ColorDrawable(-00000);
  		mView.setBackgroundDrawable(dw);
            
  		mWidth = width;
        mHeight = height;
        
        this.setGravity(Gravity.CENTER_VERTICAL);
        this.setBackgroundColor(Color.parseColor("#b0000000"));
		this.setLayoutParams(LP_FF);
		this.setOrientation(VERTICAL);
		this.addView(mView);
		
		asyncLoadFlipChartItems();
		
	
	}

	private int Calc() {
		int RecordCount = 0;
		
		RecordCount = mFlipChartSrv.getRowCount();
		return RecordCount;

	}

	// 计算余页
	public int OverPage() {
		int pages = 0;
		if (mRecordCount % mPageSize != 0)
			pages = 1;
		else
			pages = 0;
		return pages;
	}

	// 计算余页，防止SQL语句执行时溢出查询范围
	public int ModPage() {
		int pages = 0;
		if (mRecordCount % mPageSize == 0 && mRecordCount != 0)
			pages = 1;
		else
			pages = 0;
		return pages;
	}

	public void showNext() {
		// TODO Auto-generated method stub

		if (mCurrentPage + 1 > mPageCount)
			return;

		mCurrentPage++;

		mFlipChartItems.clear();
		// mFlipChartItems = new ArrayList<SaleListItem>();
		mAdapter.notifyDataSetInvalidated();
		asyncLoadFlipChartItems();

	}

	public void showPrevious() {
		// TODO Auto-generated method stub
		if (mCurrentPage - 1 < 1)
			return;

		mCurrentPage--;

		mFlipChartItems.clear();
		// mFlipChartItems = new ArrayList<SaleListItem>();
		mAdapter.notifyDataSetInvalidated();
		asyncLoadFlipChartItems();

	}
	
	public void show(){
		
//		mTextViewTotal.setText(MoleQUtil.fixNumber(mTransMgr.getAmountPayable()));
		
		if (mPopupWindow == null ) {

			// mPop = new PopupWindow(this, displayMetrics.widthPixels,
			// displayMetrics.heightPixels);
			mPopupWindow = new PopupWindow(this, this.mWidth, this.mHeight);

			// mPopupWindow.setAnimationStyle(R.style.PopupAnimation);

//			mPopupWindow.setBackgroundDrawable(getResources().getDrawable(
//					R.drawable.rounded_corners_pop));
			mPopupWindow.setFocusable(true);
			mPopupWindow.update();
			
		}

		if (!mPopupWindow.isShowing()) {
			resetItemDisplayInfo();
			
			mPopupWindow.showAtLocation(mInflater.inflate(R.layout.activity_sale, null),
					Gravity.CENTER_VERTICAL, 0, 0);
			
			mIsShowing = true;
			
		}
		
		
	}
	
	public void hide(){
		if (mPopupWindow.isShowing()) {
			mPopupWindow.dismiss();
			
			mTextViewContent1.setText("");
			mTextViewContent2.setText("");
			mTextViewTotal.setText(MoleQUtil.fixNumber(0));
			mTextViewUnitPrice.setText(MoleQUtil.fixNumber(0));
			
			mIsShowing = false;
		}
	}
	
	public boolean isShowing(){
		return mIsShowing;
	}

	public void setOnTouchSaleItemListener(OnTouchFlipChartListener listener) {
		this.mOnTouchFlipChartListener = listener;
	}
	
	
	private OnClickListener onClickListener = new OnClickListener(){

		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch( v.getId()){
			case R.id.imageButtonClose:
			
				hide();
//				mAdapter.notifyDataSetChanged();
//				update(0, 0);
//				setFocusable(false);
//				mOnItemClickLisener.onItemClickLisener(FunctionOption.FLIP_CHART_CLOSE, 0);
//				dismiss();
				break;
			case R.id.imageButtonCross:
				InputQtyInfoDialog mInputQtyInfoDialog = new InputQtyInfoDialog(mContext, FlipChartPanel.this);
				mInputQtyInfoDialog.show();
				break;
			default:
				//
				break;
			}
			
		}
		
	};
	
	
	class FlipChartRowAdapter extends BaseAdapter {

		private Context mContext;
//		private Context mShareContext;
		private LayoutInflater mInflater;
		private ArrayList<SaleListItem> mFlipChartItems;
		private ArrayList<Integer> mRows;

		private AsyncImageLoader imageLoader;
		private int mNumColumns = 1;
		private int mRecordCount;
		private int mRowCount;
		private int mOverRecordCount;
		private ItemPicService mPicService;
		private  static final String TAG ="inner FlipChartRowAdapter ";
		
		private int mIndex = -1;

		public FlipChartRowAdapter(Context context) {
			mContext = context;
			mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//			mPicService = new ItemPicService(context, shareContext);
			imageLoader = new AsyncImageLoader(); 
//			imageLoader.setItemPicService(mPicService);
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return mRows.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return mRows.get(position);
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}


		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			
			Log.i(TAG, "============ start =============");
			Log.i(TAG, "This is position: " + String.valueOf(position));
			
			View rowView  = convertView;
			FlipChartItemViewCache viewCache;
			
			if(rowView == null){
				
				Log.i(TAG,"convertView == null,Then inflate and findViewById");
				
//				rowView = buildRowView( mRows.get(position));
//				viewCache = new FlipChartItemViewCache(rowView);
				
				viewCache = new FlipChartItemViewCache(mContext,mNumColumns);
				viewCache.setItemOnTouchListener(mItemOnTouchListener);
				rowView = viewCache.getView();
				rowView.setTag(viewCache);
			}else{
				
				Log.i(TAG,"convertView != null,Then findViewById(get Holder)"); 
				
				viewCache = (FlipChartItemViewCache) rowView.getTag(); 
				
			}
			
			
			if(viewCache != null){
				Log.i(TAG,"convertView != null,Then SetValue"); 
				viewCache.setValue(mFlipChartItems,position,mIndex);
			}
			
		
			Log.i(TAG, "============ end =============");
			Log.i(TAG, "");
			return rowView;
		}
		
		private OnTouchListener mItemOnTouchListener =  new OnTouchListener(){

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					SmartBeep.getInstance().play(SmartBeep.SOUND_CLICK);
				}
				if (event.getAction() == MotionEvent.ACTION_UP) {
					
					mIndex = (Integer) v.getTag();
					
					SaleListItem prod = mFlipChartItems.get(mIndex);
					double receiveWeight = 0;
					prod.setQty(qty);
					prod.setPrice(prod.getQty() * prod.getUnitPrice());
//					if (prod.getIsWeight()) {
//						if (!mDeviceMgr.scaleIsReady) {
//							MessageBox.show(mContext, getResources().getString(R.string.msg_no_weight));
//							return false;
//						}
//
//						prod.setQty(1);
//						receiveWeight = mDeviceMgr.scale.getWeight();
//						receiveWeight = BigDecmialTool.round(receiveWeight, GlobalInfo.getInstance().decimalPoint);
//
//						// no weight
//						if (receiveWeight == 0) {
//							mDeviceMgr.disableAllScanner();
//							MessageBox.show(mContext, getResources().getString(R.string.msg_no_weight));
//							return false;
//						}
//						prod.setBaseweight(receiveWeight);
//						prod.setWeight(receiveWeight);
//						prod.setPrice(prod.getUnitPrice() * receiveWeight);
////						prod.setWeightDesc(weigthdesc);
//						// tare larger than weight not thing to do .
//						List<TareSetting> mTareSetting = ServiceManager.getInstance().mTareSettingService.Find(prod.getUpc());
//						double tmpTareweight = 0;
//						if (mTareSetting != null && mTareSetting.size() > 0) {
//							prod.setmTareSetting(mTareSetting);
//							tmpTareweight = BigDecmialTool.round(mTareSetting.get(0).getTa_value() * GlobalInfo.getInstance().tareRate, GlobalInfo.getInstance().decimalPoint);
//							prod.setTareWeight(tmpTareweight);
//						}
//						
//						double itemTare = prod.getTareWeight();
//						if (itemTare > receiveWeight)
//							return false;
//						
//						if (itemTare > 0) {
//							receiveWeight = receiveWeight - itemTare;
//						}else{
//							if (itemTare > 0) {
//								receiveWeight = receiveWeight - itemTare;
//							}
//	
//							prod.setWeight(receiveWeight);
//							prod.setPrice(prod.getUnitPrice() * receiveWeight);
//	
//							if (itemTare == 0 && mTransMgr.manualTare > 0) {
//								double tmptare = mTransMgr.manualTare * GlobalInfo.getInstance().tareRate;
//								receiveWeight = prod.getWeight() - tmptare;
//							}
//						}
//						
//						prod.setPrice(prod.getUnitPrice() * receiveWeight);
//					}
//					
//					prod.setWeight(receiveWeight);
//					displayItem(prod);
					
					
					
					v.requestFocusFromTouch();
					
					mOnTouchFlipChartListener.onFlipChartItemClick(prod);
				}
				
				return true;
			}
			
		};
		
		
		public View buildRowView(int iRow){
			LinearLayout ll = new LinearLayout(mContext);
			
			ll.setFocusable(true);
			ll.setFocusableInTouchMode(true);
		 
			int k = mNumColumns;
			if(mOverRecordCount > 0 && iRow == mRowCount -1){
				k = mOverRecordCount;
			}
			
			int currentIdx = 0;
			int row = mRows.get(iRow);
			int rowIdx = row * mNumColumns;
			for(int i = 0 ;i< k;i ++){
				currentIdx = rowIdx + i;
				ll.addView(buildColumnView(mFlipChartItems.get(currentIdx)));
			}
			
			return ll;
		}
		
		public View buildColumnView(SaleListItem item){
			ViewCache viewCache;
			View singleItemView ;
			
			singleItemView = mInflater.inflate(R.layout.flip_chart_item, null);
			viewCache = new ViewCache(singleItemView); 
			singleItemView.setTag(viewCache);
			
			RelativeLayout rl = (RelativeLayout)singleItemView.findViewById(R.id.flipChartItemContainer);
			
			LayoutParams lp = new LayoutParams(130,130);
			
			rl.setLayoutParams(lp);
			rl.setFocusable(true);
			rl.setFocusableInTouchMode(true);
			
			
			String imageUrl = item.getUpc();//imageAndText.getImageUrl();  
			final ImageView imageView = viewCache.getImageView();
			imageView.setTag(imageUrl);
			
//			imageView = hppr.imageViewPhoto;
			Drawable cachedImage = imageLoader.loadDrawable(imageUrl,new ImageCallback() {

						public void imageLoaded(Drawable imageDrawable,String imageUrl) {
							
//							ImageView imageViewByTag = (ImageView) mGridView.findViewWithTag(imageUrl);  
//		                    if (imageViewByTag != null) {  
//		                        imageViewByTag.setImageDrawable(imageDrawable);  
//		                    }  
//							
							imageView.setImageDrawable(imageDrawable);
							
							
						}
					});
			
			if (cachedImage == null) {  
	           // imageView.setImageResource(R.drawable.default_image);  
	        }else{  
	            imageView.setImageDrawable(cachedImage);  
	        }  
	        
			viewCache.getTextView().setText(item.getDisplayContent()); 
	        viewCache.getTextView2().setText(item.getDescription());
	        
	        if(item.getIsWeight()){
	        	rl.setBackgroundResource(R.drawable.bg_scalable_flip_chart_item_states);
			}else{
				rl.setBackgroundResource(R.drawable.bg_regular_flip_chart_item_states);
			}
	        
	       rl.setOnTouchListener(mItemOnTouchListener);
	       //rl.setOnClickListener(mItemOnClickListener );
	        rl.setTag(item);
			return singleItemView;
			
		}
		
		public void setNumColumns(int numColumns){
			if(numColumns <= 0){
				mNumColumns = 1;
			}else{
				mNumColumns  = numColumns;
			}
			
		}

		public void setSource(ArrayList<SaleListItem> mFlipChartItems2) {
			
			mRecordCount = mFlipChartItems2.size();
			mRowCount = mRecordCount / mNumColumns + OverRow();
			mOverRecordCount = mRecordCount % mNumColumns;
			
			mRows = new ArrayList<Integer>();
			for(int i = 0 ; i< mRowCount ; i++){
				mRows.add(i);
			}
			
			this.mFlipChartItems = mFlipChartItems2;
			
		}
		
		public int OverRow() {
			int pages = 0;
			if (mRecordCount % mNumColumns != 0)
				pages = 1;
			else
				pages = 0;
			return pages;
		}

	}
	
	
	private boolean mLoadItemSwitch = false;
	protected Thread mLoadItemThread = null;

	public void asyncLoadFlipChartItems() {

		
		mLoadItemSwitch = true;
		// mScannerPause = false;
		if (mLoadItemThread == null) {
			mLoadItemThread = new Thread(new Runnable() {
				@Override
				public void run() {

					loadItemsWork();

				}

			});

			mLoadItemThread.setDaemon(true);
			mLoadItemThread.start();
		}

		if (mLoadItemThread.getState() != Thread.State.TERMINATED) {

		} else {

			mLoadItemThread = new Thread(new Runnable() {
				@Override
				public void run() {

					loadItemsWork();

				}
			});
			mLoadItemThread.setDaemon(true);
			mLoadItemThread.start();
		}

	}

	private void loadItemsWork() {
		while (mLoadItemSwitch) {

			try {
//				mLoadItemThread.sleep(500);
				Thread.sleep(500); 
				
				if (mPopupWindow != null && mPopupWindow.isShowing()) {

					Message message = mLoadItemHandler.obtainMessage(1, "");
					mLoadItemHandler.sendMessage(message);

					mLoadItemSwitch = false;
				}
				
				  

			} catch (Exception ex) {
				ex.printStackTrace();
			}

		}

	}

	
	private final Handler mLoadItemHandler = new Handler() {

		@Override
		public void handleMessage(Message msg) {

			switch (msg.what) {
			case 1:
				
				///mRecordCount
				List<FlipChart> items = mFlipChartSrv.getAllFlipChart();
				int rowCount = items.size();
				int maxPage = rowCount % mPageSize;
				
				 for (int i = 0;i < rowCount; i++){
					 
					 SaleListItem mSaleListitem;
					 mSaleListitem = new SaleListItem();
					 String tmp = items.get(i).getUpc();
					
					 Product product = mProductService.Find(tmp);
					 mSaleListitem.setName(product.getName1());
					 mSaleListitem.setDisplayContent(product.getName1());
					 mSaleListitem.setUnitPrice(product.getPrice());
					 mSaleListitem.setQty(1);
					 mSaleListitem.setPrice(mSaleListitem.getUnitPrice()* mSaleListitem.getQty());
					 mSaleListitem.setUpc(product.getBarcode());
					 mSaleListitem.setDescription(product.getDesc());
					 mSaleListitem.setIsWeight(product.isWeight());
					 mSaleListitem.setIscoupon(product.getIscoupon());
					 mSaleListitem.setFollowdep(product.getFollowdep());
					 
					 deptSetting = mSubDepartmantService.Find(product.getDep());
					 if (mSaleListitem.getFollowdep() && deptSetting != null) {
						 mSaleListitem.setIsWeight(deptSetting.getScale_weight());
					 }
					 mFlipChartItems.add(mSaleListitem);
					 mAdapter.notifyDataSetChanged();
				 }
				mFlipChartSrv.getRowCount();
				
				mAdapter.setSource(mFlipChartItems);
				break;
				
			}

		}
	};
	
	
	public  String repeatString(String s, int n) {
		// TODO Auto-generated method stub
		if (n <= 0) return"";
		return String.format(String.format("%%0%dd",n), 0).replace("0", s);
	}
	
	
	private void resetItemDisplayInfo(){
		
//		mIndex = -1;
//		mAdapter.notifyDataSetChanged();
		mListView.requestFocusFromTouch();
		mTextViewContent1.setText("");
		mTextViewContent2.setText("");
		mTextViewWeight.setText("");
		mTextViewUnitPrice.setText(MoleQUtil.fixNumber(0));
		mTextViewTotal.setText(MoleQUtil.fixNumber(mTransMgr.getAmountPayable()));
		mtextViewMultiplier.setText("1");
		qty = 1;
	}

	
	public void displayItem(SaleListItem item){
		mTextViewContent1.setText(item.getName());
		mTextViewContent2.setText(item.getDescription());
		
//		if(item.getIsWeight()){
////			mTextViewWeight.setText(MoleQUtil.fixNumber(item.getWeight()) + GlobalInfo.getInstance().weightUnit);
//			String weightDesc = MoleQUt3333il.fixNumber(item.getWeight()) + GlobalInfo.getInstance().weightUnit+" " + 
//					GlobalInfo.getInstance().CurrencySign + MoleQUtil.fixNumber(BigDecmialTool.round(item.getUnitPrice(),2))
//					+"/"+ GlobalInfo.getInstance().weightUnit;
//			mTextViewWeight.setText(weightDesc);
//		}else{
//			
//			if (item.getQty() > 1) {
//				mTextViewWeight.setText(MoleQUtil.fixPriceForScreen(item.getUnitPrice())+" EACH");
//			}else{
//				mTextViewWeight.setText("");
//			}
//		}
		mTextViewWeight.setText(item.getPriceDescription()+item.getEachDescription());
		mTextViewUnitPrice.setText(MoleQUtil.fixNumber(item.getPrice()));
		mtextViewMultiplier.setText(String.valueOf(item.getQty()));
		qty = 1;
		
		mDeviceMgr.screen.displayLine(item.getName()+ "\n" + " "
				+ MoleQUtil.fixNumber(item.getPrice()));
	}
	
	
	private void refreshDisplayContent(){
		mTextViewTotal.setText(MoleQUtil.fixNumber(mTransMgr.getAmountPayable()));
	}
	

	
	public  interface OnTouchFlipChartListener{
		void onFlipChartItemClick(SaleListItem item);
	}
	
	@Override
	public void onShowItem(SaleListItem item) {
		displayItem(item);
		
	}

	@Override
	public void onAnnounceCartChanges() {
		// TODO Auto-generated method stub
		refreshDisplayContent();
		
	}

	@Override
	public void onSelectedIndex(int idx) {
		// TODO Auto-generated method stub
		
	}

	public void dispose() {
		mLoadItemSwitch = false;
		
	}

	@Override
	public void onNoItemInList() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onCloseWithReturn(Class<? extends MoleQBaseDialog> pramClass,
			int viewId, String returnvalue) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onReturnValue(int what, Object obj) {
		// TODO Auto-generated method stub
		int result = Integer.valueOf(obj.toString());
		if (result >= 1) {
			qty = result;
			mtextViewMultiplier.setText(String.valueOf(qty));
		}
		
	}

	@Override
	public void onShowingMessageDlg(boolean isShowing) {
		// TODO Auto-generated method stub
		
	}

}
